package com.longge;

public class ClearDigits {

    public String clearDigits(String s) {
        if (s.length() == 0) return s;
        char[] chars = s.toCharArray();
        StringBuilder sb = new StringBuilder();
        boolean flag = true;
        for (int i = 0; i < chars.length; i++) {
            char aChar = chars[i];
            sb.append(aChar);
            if (Character.isDigit(aChar) && flag) {
                flag = false;
                sb.deleteCharAt(i );
                if (i != 0) {
                    sb.deleteCharAt(i - 1);
                }
            }
        }
        if (s.length() == sb.length()) return s;
        s = clearDigits(sb.toString());
        return s;
    }
}
